<template>
    <div>
        <h2>页面添加</h2>
        <table class="table">
            <thead>
                <tr>
                    <td>姓名</td>
                    <td><input type="text" name="" v-model="data.Name"></td>
                </tr>
         
                <tr>
                    <td>邮箱</td>
                    <td><input type="text" name="" v-model="data.Email"></td>
                </tr>

                <tr>
                    <td>生日</td>
                    <td><input type="date" name="" v-model="data.Birthday"></td>
                </tr>

                <tr>
                    <td>城市</td>
                    <td><input type="text" name="" v-model="data.City"></td>
                </tr>

                <tr>
                    <td>性别</td>
                    <td>
                    <input type="radio" name="sex" value="1" checked v-model="data.Sex">男
                    <input type="radio" name="sex" value="2" v-model="data.Sex">女
                    </td>
                </tr>

            </thead>
        </table>
        <input type="button" value="修改" @click="Add">
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import {ref,onMounted} from 'vue';
import { useRouter } from 'vue-router';

const Show=()=>{
    axios.get("https://localhost:7068/api/Vip/GetDet",{params:{Id:localStorage["Id"]}}).then(res=>{
        data.value=res.data;
        data.value.Birthday = moment(data.value.Birthday).format('YYYY-MM-DD');
    })
}

onMounted(() => {
    Show();
})

const data =ref ({
  "Id": localStorage["Id"],
  "Name": "",
  "Email": "",
  "Birthday": "",
  "City": "",
  "Sex": 0,
  "Del": true
})

const Add=()=>{
    axios.post("https://localhost:7068/api/Vip/UptVip",data.value).then(res=>{
        if(res.data>0){
            alert("修改成功");
            location.href="/";
        }
        else{
            alert("修改失败");
        }
    })
}

</script>

<style scoped>

</style>